﻿using Cherry.Agile.Enterprise.Entity;
using Cherry.Agile.Framework.Query;
using System;
using System.Collections.Generic;
using System.Linq;
using System.ServiceModel;
using System.Text;
using System.Threading.Tasks;

namespace Cherry.Agile.Enterprise.Services.Interface
{
    [ServiceContract(Namespace = Unity.Namespace)]
    public interface IRoleService
    {
        /// <summary>
        /// 获取所有角色
        /// </summary>
        /// <returns>角色集合</returns>
        [OperationContract]
        List<RoleInfo> SyncRoleInfo();

        /// <summary>
        /// 获取所有角色
        /// </summary>
        /// <returns>角色集合</returns>
        [OperationContract]
        List<RoleInfo> GetRoles();

        /// <summary>
        /// 增加角色信息
        /// </summary>
        /// <param name="roleInfo">角色信息</param>
        [OperationContract]
        RoleInfo AddRole(RoleInfo roleInfo);

        /// <summary>
        /// 修改角色信息
        /// </summary>
        /// <param name="roleInfo">角色信息</param>
        [OperationContract]
        void UpdateRole(RoleInfo roleInfo);

        /// <summary>
        /// 删除角色信息
        /// </summary>
        /// <param name="roleId">角色ID</param>
        [OperationContract]
        void DeleteRole(int[] roleId);

        /// <summary>
        /// 获取医生的角色
        /// </summary>
        [OperationContract]
        List<RoleInfo> GetRoleForDoctorList();

        /// <summary>
        /// 获取某组织下的医生角
        /// </summary>
        /// <param name="orgId">组织ID</param>
        [OperationContract]
        List<RoleInfo> GetOrgRoleForDoctorList(int orgId);

        /// <summary>
        /// 获取角色 包含某单位下的角色和系统角色。不包含超级管理员角色
        /// </summary>
        /// <param name="orgId">组织ID</param>        
        [OperationContract]
        List<RoleInfo> GetOrgAndSystemRoleForDoctorList(int orgId);

        /// <summary>
        /// 获取非系统的医生角色
        /// </summary>
        /// <param name="orgId">组织Id</param>
        /// <returns>角色列表</returns>
        [OperationContract]
        List<RoleInfo> GetNonSystemRolesByOrgId(int orgId);

        /// <summary>
        /// 获取会员的角色列表
        /// </summary>
        /// <param name="roleName">会员角色名称</param>
        /// <param name="paging">分页信息</param>
        /// <returns>会员角色列表</returns>
        [OperationContract]
        List<RoleInfo> GetPatientRoleByRoleName(string roleName, Pagination paging);


        /// <summary>
        /// 获取医生的角色
        /// </summary>
        [OperationContract]
        List<RoleInfo> GetOrgRoleForPatientList();

        /// <summary>
        /// 增加角色菜馆练练系想你
        /// </summary>
        /// <param name="roleMenuInfo">角色菜单信息</param>
        [OperationContract]
        void AddRoleMenu(RoleMenuInfo roleMenuInfo);

        /// <summary>
        /// 删除角色菜单关联信息
        /// </summary>
        /// <param name="roleMenuId">关联ID</param>
        [OperationContract]
        void DeleteRoleMenu(int roleMenuId);

        /// <summary>
        /// 查询角色菜单关联信息
        /// </summary>
        /// <param name="roleId">角色ID</param>
        /// <returns>角色菜单关联信息</returns>
        [OperationContract]
        List<RoleMenuInfo> GetRoleMenuListByRoleId(int roleId);

        /// <summary>
        /// 增加角色功能点关联信息
        /// </summary>
        /// <param name="roleFunctionInfo">角色功能点信息</param>
        [OperationContract]
        void AddRoleFunction(RoleFuncInfo roleFunctionInfo);



        /// <summary>
        /// 根据组织id获取角色信息列表
        /// </summary>
        /// <param name="orgID">组织ID</param>
        /// <returns>角色信息列表</returns>
        [OperationContract]
        List<RoleInfo> GetRoleInfoByOrgID(int orgID);

        /// <summary>
        /// 根据角色id获取角色信息
        /// </summary>
        /// <param name="roleID">角色id</param>
        /// <returns>角色信息</returns>
        [OperationContract]
        RoleInfo GetRoleInfoByID(int roleID);

        /// <summary>
        /// 检查角色名称是否存在
        /// </summary>
        /// <param name="roleType">角色类型</param>
        /// <param name="roleName">角色名称</param>
        /// <returns>角色名称是否存在</returns>
        [OperationContract]
        bool CheckRoleNameIsExists(sbyte roleType, string roleName);
        /// <summary>
        /// 检查同组织下是否有同名的角色
        /// </summary>
        /// <param name="orgID"></param>
        /// <param name="roleName"></param>
        /// <returns></returns>
        [OperationContract]
        bool IsRoleNameExists(int orgID, string roleName);

        ///// <summary>
        ///// 取角色的菜单和功能点，用于导出
        ///// </summary>
        ///// <param name="roleId">角色</param>
        ///// <returns>角色的菜单和功能点</returns>
        //[OperationContract]
        //List<MenusAndFunctionsOfRole> GetMenusAndFunctionsByRoleId(int roleId);

        /// <summary>
        /// 导入角色
        /// </summary>
        /// <param name="orgId">组织Id</param>
        /// <param name="roleName">角色名称</param>
        /// <param name="menus">角色</param>
        /// <param name="functions">功能点</param>
        /// <param name="creator">创建者</param>
        /// <returns>1表示成功，2表示角色名称已存在</returns>
        [OperationContract]
        string ImportRole(int orgId, string roleName, int[] menus, int[] functions, string creator);
    }
}
